export default {
  form_ods_sale_register: {
    _odoo_model: 'ir.ui.view',
    model: 'fp.ods.sale.register',
    type: 'form',

    arch: {
      buttons: [
        {
          name: 'create_sale_order',
          string: '创建销售订单',
          type: 'object',
          btn_type: 'primary'
        }
      ]
    },

    fields: {
      company_id: {},
      partner_id: {},
      sale_order_id: {
        domain({ record }) {
          const { company_id, partner_id } = record

          console.log(record, company_id, partner_id)
          return [
            ['state', '=', 'draft'],
            ['company_id', '=', company_id && company_id[0]],
            ['partner_id', '=', partner_id && partner_id[0]]
          ]
        }
      },

      sale_line_ids: {
        string: '已加入明细',
        widget: 'x2many_tree',
        views: {
          tree: {
            fields: {
              sequence: {},
              product_id: {},
              product_categ_id: {},
              product_categ_code: {},
              product_categ_name: {},
              product_name: {},
              product_spec: {},
              uom_name: {},
              tax_ratio: {},

              quantity: {},
              price_unit: {},

              amount_untaxed: {},
              amount_tax: {},
              amount_total: {}
            }
          },
          form: {
            fields: {
              sequence: {},
              product_id: {},
              product_categ_id: {},
              product_categ_code: {},
              product_categ_name: {},
              product_name: {},
              product_spec: {},
              uom_name: {},
              tax_ratio: {},

              quantity: {},
              price_unit: {},

              amount_untaxed: {},
              amount_tax: {},
              amount_total: {}
            }
          }
        }
      },

      line_ids: {
        string: '待加入明细',
        widget: 'x2many_tree',
        views: {
          tree: {
            fields: {
              sequence: {},
              product_id: {},
              product_categ_id: {},
              product_categ_code: {},
              product_categ_name: {},
              product_name: {},
              product_spec: {},
              uom_name: {},
              tax_ratio: {},

              quantity: {},
              price_unit: {},

              amount_untaxed: {},
              amount_tax: {},
              amount_total: {}
            }
          },
          form: {
            fields: {
              sequence: {},
              product_id: {},
              product_categ_id: {},
              product_categ_code: {},
              product_categ_name: {},
              product_name: {},
              product_spec: {},
              uom_name: {},
              tax_ratio: {},

              quantity: {},
              price_unit: {},

              amount_untaxed: {},
              amount_tax: {},
              amount_total: {}
            }
          }
        }
      }
    }
  },

  action_ods_to_sale_order: {
    _odoo_model: 'ir.actions',
    name: 'ods to sale',
    type: 'ir.actions.act_window',
    res_model: 'fp.ods.sale.register',
    domain: [],
    context: {
      active_model: 'fp.ods.sale.order'
    },
    views: {
      form: 'form_ods_sale_register'
    }
  }
}
